<template>
  <div v-loading="$store.state.pageLoading" class="app-container dashboard-editor-container" element-loading-text="数据加载中...">
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
      <el-tab-pane v-for="(item, index) in $store.state.channelList" :lazy="true" :label="item" :name="index + ''" :key="index">
        <div style="padding:0 30px 30px">
          <el-row type="flex" justify="space-between">
            <el-col v-for="(item, index) in  $store.state.lineChartDataChannelList.barData" :span="6" :key="index">
              <p>{{ item.name }}到场人数：{{ item.amount || 0 }}人</p>
              <p>{{ item.name }}到场率：{{ item.zdcrate*100 + '%' || 0 }}</p>
            </el-col>
          </el-row>
        </div>
        <el-row style="background:#fff;padding:16px 5px 0 ;margin-bottom:32px;">
          <line-chart v-if="$store.state.showChannelList" :chart-data=" $store.state.lineChartDataChannelList" />
        </el-row>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import { channelList } from "@/api/activity";
import LineChart from "../../components/LineChart";

export default {
  components: { LineChart },
  data() {
    return {
      activeName: "0" // table栏默认激活项
    };
  },
  created() {
    this.$store.state.channelListTime.startDate = null;
    this.fetchData();
  },
  methods: {
    async handleClick(tab) {
      // 切换table栏
      this.$store.state.channelListTime.startDate = tab.label;
      this.fetchData();
    },
    async fetchData() {
      channelList({
        activityId: this.$store.state.thisActivityId,
        startDate: this.$store.state.channelListTime.startDate
      });
    }
  }
};
</script>
